<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-us" xml:lang="en-us">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="DC.Type" content="topic">
  <meta name="DC.Title" content="Script Format Requirements of Different OSs">
  <meta name="product" content="">
  <meta name="DC.Relation" scheme="URI" content="en-us_topic_0000002200005713.html">
  <meta name="prodname" content="">
  <meta name="version" content="">
  <meta name="brand" content="">
  <meta name="DC.Publisher" content="20250306">
  <meta name="documenttype" content="usermanual">
  <meta name="prodname" content="csbs">
  <meta name="DC.Format" content="XHTML">
  <meta name="DC.Identifier" content="EN-US_TOPIC_0000002164604938">
  <meta name="DC.Language" content="en-us">
  <link rel="stylesheet" type="text/css" href="public_sys-resources/commonltr.css">
  <title>Script Format Requirements of Different OSs</title>
 </head>
 <body style="clear:both; padding-left:10px; padding-top:5px; padding-right:5px; padding-bottom:5px">
  <a name="EN-US_TOPIC_0000002164604938"></a><a name="EN-US_TOPIC_0000002164604938"></a>
  <h1 class="topictitle1">Script Format Requirements of Different OSs</h1>
  <div>
   <p id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_p1060131207">Different OSs have different requirements on the formats of executable scripts, as described in <a href="#EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_table1957573910211">Table 1</a>.</p>
   <div class="tablenoborder">
    <a name="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_table1957573910211"></a><a name="en-us_topic_0000002200061449_table1957573910211"></a>
    <table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_table1957573910211" frame="border" border="1" rules="all">
     <caption>
      <b>Table 1 </b>Script format requirements
     </caption>
     <colgroup>
      <col style="width:33.33%">
      <col style="width:33.33%">
      <col style="width:33.33%">
     </colgroup>
     <thead align="left">
      <tr id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_row115762393219">
       <th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.2.2.4.1.1"><p id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_p157612396212">OS Type</p></th>
       <th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.2.2.4.1.2"><p id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_p175761839427">Script Type</p></th>
       <th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.2.2.4.1.3"><p id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_p188217111433">Command Output Description</p></th>
      </tr>
     </thead>
     <tbody>
      <tr id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_row2736942899">
       <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_p1273616421097">Windows</p></td>
       <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_p773614426912">.bat</p></td>
       <td class="cellrowborder" rowspan="4" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_p7231815134218">If <strong id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_b103371652154516">0</strong> is returned, the script is executed successfully. If a non-zero value is returned, the script fails to be executed.</p></td>
      </tr>
      <tr id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_row2576939425">
       <td class="cellrowborder" valign="top" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_p857683919219">Linux</p></td>
       <td class="cellrowborder" valign="top" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_p1657612391320">.sh</p></td>
      </tr>
      <tr id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_row857619399215">
       <td class="cellrowborder" valign="top" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_p457619391424">AIX</p></td>
       <td class="cellrowborder" valign="top" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_p1667795610416">.sh</p></td>
      </tr>
      <tr id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_row1257610392211">
       <td class="cellrowborder" valign="top" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_p1257617391327">Solaris</p></td>
       <td class="cellrowborder" valign="top" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_p7109105712415">.sh</p></td>
      </tr>
     </tbody>
    </table>
   </div>
   <ul id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_ul15519193994618">
    <li id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_li1751914399463">Example of the <strong id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_b65891120474">.sh</strong> script:<pre class="screen" id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_screen1057442384516">#!/bin/sh
set +x
#####################################################################
# The function of this script is to start the ProtectAgent service.
#####################################################################
AGENT_USER=rdadmin
AGENT_GROUP=rdadmin
SANCLIENT_USER=sanclient
SANCLIENT_GROUP=sanclient
UNIX_CMD=
SANCLIENT_INSTALL_PATH="/opt/DataBackup/SanClient"
SYS_NAME=`uname -s`
ROCKY4_FLAG=0
SHELL_TYPE_SH="/bin/sh"
USER_NOLOGIN_SHELL="/sbin/nologin"
BACKUP_ROLE_SANCLIENT_PLUGIN=5
CURRENT_PATH=`dirname $0` &amp;&amp; cd $CURRENT_PATH &amp;&amp; CURRENT_PATH=`pwd`
LO_IP_IPV4="127.0.0.1"
. ${CURRENT_PATH}/func_util.sh
SelectStart()
{
    if [ -d "$INSTALL_PATH" ]; then
        if [ "${SYS_NAME}" = "AIX" ] || [ "${SYS_NAME}" = "SunOS" ]; then
            su - ${AGENT_USER} -c "${EXPORT_ENV}${INSTALL_PATH}/ProtectClient-E/bin/agent_start.sh"
        else
            su - ${AGENT_USER} -s ${SHELL_TYPE_SH} ${UNIX_CMD} -c "${EXPORT_ENV}\"${INSTALL_PATH}/ProtectClient-E/bin/agent_start.sh\""
        fi
        if [ $? -ne 0 ]; then
            echo "Failed to start the DataBackup ProtectAgent, error exit."
            exit 1
        fi
    else
        echo "Not install any client,the startup will be stopped."
        return 1
    fi
    return 0
}
# Start the service process.
SelectStart
exit $?</pre></li>
    <li id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_li2050835015469">Example of the .bat script:<pre class="screen" id="EN-US_TOPIC_0000002164604938__en-us_topic_0000002200061449_screen2037718719473">@echo off
setlocal EnableDelayedExpansion
::The script is used to start Agent Service.
set PARAM1=%~1
set CURRENT=%~dp0
set NUMBER=0
echo Begin start DataBackup ProtectAgent services...
echo.
rem start rdagent service
call :startservice rdagent
if not "!errorlevel!" == "0" (exit /b 1)
endlocal
exit /b 0
:startservice
    set SERVICE_CHECK=
    set SERVICE_NAME=%~1
    set RETRY_COUNT=1
    set SC_RETRY_COUNT=1
    call :checkservice !SERVICE_NAME!
    if %errorlevel% EQU 2 (
        call :Log "The service !SERVICE_NAME! of DataBackup ProtectAgent is not exist, it is a normal situation during the upgrade process."
        exit /b 0
    )
    if not "!errorlevel!" == "0" (
        echo The service !SERVICE_NAME! of DataBackup ProtectAgent is not exist.
        call :Log "The service !SERVICE_NAME! of DataBackup ProtectAgent is not exist."
		call :Winsleep 3
        exit /b 1
    )
    for /f "delims=" %%i in ('2^&gt;nul sc query !SERVICE_NAME! ^| find "RUNNING"') do (set SERVICE_CHECK=%%i)
    exit /b 0
:</pre></li>
   </ul>
  </div>
  <div>
   <div class="familylinks">
    <div class="parentlink">
     <strong>Parent topic:</strong> <a href="en-us_topic_0000002200005713.html">FAQs</a>
    </div>
   </div>
  </div>
 </body>
</html>